clear
clc

data_dir = 'D:/Work/EMTD-code/res/';

fig1 = figure;
set(gcf, 'position', [0, 0, 1600, 600]);

%% subplot: Adw
subplot_adw = subplot(1,4,1);

data_name = 'CTU_Normal_vs_Adw_mv';
load([data_dir, data_name, '_res.mat'])

yyaxis(subplot_adw,'left');
plot([1:100], losses, 'DisplayName','Loss', 'LineStyle', '-', 'LineWidth',1.5,'Color',[0 0 0]);
ylim([0 1e-6]);
ylabel('Loss');
set(subplot_adw,'YColor',[0 0 0]);

yyaxis(subplot_adw,'right');
plot([1:100], fprs, 'DisplayName','FPR','LineStyle', '-','LineWidth',1.5, 'Color',[0 0.447058823529412 0.741176470588235]); hold on;
plot([1:100], fnrs, 'DisplayName','FNR','LineStyle', '-','LineWidth',1.5, 'Color',[0.850980392156863 0.325490196078431 0.0980392156862745]); hold on;
plot([1:100], error_rates, 'DisplayName','Error Rate','LineStyle', '-','LineWidth',1.5, 'Color',[0.929411764705882 0.694117647058824 0.125490196078431]);
ylim([0 01]);
ylabel('Metric (%)');
set(subplot_adw,'YColor',[0 0 0]);

xlabel('Epoch');
title('\fontsize{14}{Adw^+}');
set(subplot_adw, 'XTick', [1, 25, 50, 75, 100])
set(gca, 'FontSize', 12)
legend
grid on
axis square

%% subplot: Drp
subplot_drp = subplot(1,4,2);

data_name = 'CTU_Normal_vs_Drp_mv';
load([data_dir, data_name, '_res.mat'])

yyaxis(subplot_drp,'left');
plot([1:100], losses, 'DisplayName','Loss', 'LineStyle', '-', 'LineWidth',1.5,'Color',[0 0 0]);
ylim([0 0.8e-7]);
ylabel('Loss');
set(subplot_drp,'YColor',[0 0 0]);

yyaxis(subplot_drp,'right');
plot([1:100], fprs, 'DisplayName','FPR','LineStyle', '-','LineWidth',1.5, 'Color',[0 0.447058823529412 0.741176470588235]); hold on;
plot([1:100], fnrs, 'DisplayName','FNR','LineStyle', '-','LineWidth',1.5, 'Color',[0.850980392156863 0.325490196078431 0.0980392156862745]); hold on;
plot([1:100], error_rates, 'DisplayName','Error Rate','LineStyle', '-','LineWidth',1.5, 'Color',[0.929411764705882 0.694117647058824 0.125490196078431]);
ylim([-0.01 1]);
ylabel('Metric (%)');
set(subplot_drp,'YColor',[0 0 0]);

xlabel('Epoch');
title('\fontsize{14}{Drp^+}');
set(subplot_drp, 'XTick', [1, 25, 50, 75, 100])
set(gca, 'FontSize', 12)
legend
grid on
axis square

%% subplot: Rtk
subplot_rtk = subplot(1,4,3);

data_name = 'CTU_Normal_vs_Rtk_mv';
load([data_dir, data_name, '_res.mat'])

yyaxis(subplot_rtk,'left');
plot([1:100], losses, 'DisplayName','Loss', 'LineStyle', '-', 'LineWidth',1.5,'Color',[0 0 0]);
ylim([-1e-6 0.4e-4]);
ylabel('Loss');
set(subplot_rtk,'YColor',[0 0 0]);

yyaxis(subplot_rtk,'right');
plot([1:100], fprs, 'DisplayName','FPR','LineStyle', '-','LineWidth',1.5, 'Color',[0 0.447058823529412 0.741176470588235]); hold on;
plot([1:100], fnrs, 'DisplayName','FNR','LineStyle', '-','LineWidth',1.5, 'Color',[0.850980392156863 0.325490196078431 0.0980392156862745]); hold on;
plot([1:100], error_rates, 'DisplayName','Error Rate','LineStyle', '-','LineWidth',1.5, 'Color',[0.929411764705882 0.694117647058824 0.125490196078431]);
ylim([-0.1 10]);
ylabel('Metric (%)');
set(subplot_rtk,'YColor',[0 0 0]);

xlabel('Epoch');
title('\fontsize{14}{Rtk^+}');
set(subplot_rtk, 'XTick', [1, 25, 50, 75, 100])
set(gca, 'FontSize', 12)
legend
grid on
axis square


%% subplot: Susp
subplot_susp = subplot(1,4,4);

data_name = 'CTU_Normal_vs_Susp_mv';
load([data_dir, data_name, '_res.mat'])

yyaxis(subplot_susp,'left');
plot([1:100], losses, 'DisplayName','Loss', 'LineStyle', '-', 'LineWidth',1.5,'Color',[0 0 0]);
ylim([-1e-7 1e-5]);
ylabel('Loss');
set(subplot_susp,'YColor',[0 0 0]);

yyaxis(subplot_susp,'right');
plot([1:100], fprs, 'DisplayName','FPR','LineStyle', '-','LineWidth',1.5, 'Color',[0 0.447058823529412 0.741176470588235]); hold on;
plot([1:100], fnrs, 'DisplayName','FNR','LineStyle', '-','LineWidth',1.5, 'Color',[0.850980392156863 0.325490196078431 0.0980392156862745]); hold on;
plot([1:100], error_rates, 'DisplayName','Error Rate','LineStyle', '-','LineWidth',1.5, 'Color',[0.929411764705882 0.694117647058824 0.125490196078431]);
ylim([-0.01 1]);
ylabel('Metric (%)');
set(subplot_susp,'YColor',[0 0 0]);

xlabel('Epoch');
title('\fontsize{14}{Susp^+}');
set(subplot_susp, 'XTick', [1, 25, 50, 75, 100])
set(gca, 'FontSize', 12)
legend
grid on
axis square


% %% subplot: All
% subplot_all = subplot(1,5,5);
% 
% data_name = 'CTU_Normal_vs_Adw_Drp_Rtk_Susp_mv';
% load([data_dir, data_name, '_res.mat'])
% 
% yyaxis(subplot_all,'left');
% plot([1:100], losses, 'DisplayName','Loss', 'LineStyle', '-', 'LineWidth',1.5,'Color',[0 0 0]);
% ylim([-0.5e-8 0.5e-6]);
% ylabel('Loss');
% set(subplot_all,'YColor',[0 0 0]);
% 
% yyaxis(subplot_all,'right');
% plot([1:100], fprs, 'DisplayName','FPR','LineStyle', '-','LineWidth',1.5, 'Color',[0 0.447058823529412 0.741176470588235]); hold on;
% plot([1:100], fnrs, 'DisplayName','FNR','LineStyle', '-','LineWidth',1.5, 'Color',[0.850980392156863 0.325490196078431 0.0980392156862745]); hold on;
% plot([1:100], error_rates, 'DisplayName','Error Rate','LineStyle', '-','LineWidth',1.5, 'Color',[0.929411764705882 0.694117647058824 0.125490196078431]);
% ylim([0 1]);
% ylabel('Metric (%)');
% set(subplot_all,'YColor',[0 0 0]);
% 
% xlabel('Epoch');
% title('\fontsize{14}{All}');
% set(subplot_all, 'XTick', [1, 25, 50, 75, 100])
% set(gca, 'FontSize', 12)
% legend
% grid on
% axis square